# -*- coding: utf-8 -*-
# @Author : HaleShi
# @Time : 2023-06-06
# @File : 6_aes_ciper.py

from Crypto.Cipher import AES
from Crypto.Util.Padding import pad

KEY = "fd6b639dbcff0c2a1b03b389ec763c4b"
IV = "77b07a672d57d64c"


def aes_encrypt(data_string):
    aes = AES.new(
        key=KEY.encode('utf-8'),
        mode=AES.MODE_CBC,
        iv=IV.encode('utf-8')
    )
    raw = pad(data_string.encode('utf-8'), 16)
    return aes.encrypt(raw)


data = "aid=571895505&auto_play=0&build=6240300&cid=1153963912&did=NgBjUWgOPFlqD2kPcw9z&epid=&from_spmid=creation.hot-tab.0.0&ftime=1685950311&lv=0&mid=0&mobi_app=android&part=1&sid=0&spmid=main.ugc-video-detail.0.0&stime=1686036113&sub_type=0&type=3&sign=7786b2952ade9a0e1f9b54e55010ab8447b6a420120c1c3baefdc3b886561108"

# 字节类型
bytes_data = aes_encrypt(data)

result = "".join([hex(item)[2:].rjust(2, "0") for item in bytes_data])
print(result)

# 23bd50150490403f2d962eac6d5641f9edb7f58c4bc994f550e2d80ce3d7112e53d107bd65d1ee11e8e67dfb520beaba85f4a6274b522ad4f3cf8e771e8db02b219336480da497f9bc230fd193a878577c2522403f951c898fb35fe4f7de7d58b58c41a1c92953aa2c2d9190f63a4766669348dc4c19affd79dc46bf44c19f9d1fbf9b51a5105909e22ec372983028274a0b1121389bf2ed498168eb8f183e4d87c9246d70cfd83756e08215729b99fe797d0b48e0abe2b5e474a2a4cfe28685e643399d151bf27677348ed1c4b76d4a474139c7e653225c4faa17a7c66a377cfd9358aece8409c22755bfb9425440919e2d43dbcda4395a54ddfa89895b6adf0a1b3c9b53f675f264d19fc1eafae2826aaf5709ab81a93359a33c1a5729b1167851a2cfa458798354cc605eb828cff32b212bb9dcfcd68a7725cb0c3265a6fe
# 23bd50150490403f2d962eac6d5641f9edb7f58c4bc994f550e2d80ce3d7112e53d107bd65d1ee11e8e67dfb520beaba85f4a6274b522ad4f3cf8e771e8db02b219336480da497f9bc230fd193a878577c2522403f951c898fb35fe4f7de7d58b58c41a1c92953aa2c2d9190f63a4766669348dc4c19affd79dc46bf44c19f9d1fbf9b51a5105909e22ec372983028274a0b1121389bf2ed498168eb8f183e4d87c9246d70cfd83756e08215729b99fe797d0b48e0abe2b5e474a2a4cfe28685e643399d151bf27677348ed1c4b76d4a474139c7e653225c4faa17a7c66a377cfd9358aece8409c22755bfb9425440919e2d43dbcda4395a54ddfa89895b6adf0a1b3c9b53f675f264d19fc1eafae2826aaf5709ab81a93359a33c1a5729b1167851a2cfa458798354cc605eb828cff32b212bb9dcfcd68a7725cb0c3265a6fe
